//
//  bangongsiTableViewCell.m
//  PASystem
//
//  Created by michael on 16/8/17.
//  Copyright © 2016年 czd. All rights reserved.
//
#import "guoneiwaiViewController.h"
#import "bangongsiTableViewCell.h"
#import "huiyiguanliTableViewController.h"
@implementation bangongsiTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
UIColor *myColor = [UIColor colorWithWhite:0.8 alpha:0.3];
self.contentView.backgroundColor = myColor;

         view = [[UIView alloc]init ];
         
         view.backgroundColor = [UIColor whiteColor];
    
_button = [UIButton buttonWithType:UIButtonTypeCustom];

   _label = [[UILabel alloc]init];
    
    [self.contentView addSubview:view];
//        [view addSubview:_button];
//            [view addSubview:_label];

    
}

return self;

}
- (void)oneAction :(UIButton *)UIButton{

if ([_array[UIButton.tag] isEqualToString:@"国内活动"]) {
    guoneiwaiViewController *guowai = [[guoneiwaiViewController alloc]init];
        guowai.string = @"国内活动";
        guowai.type = @"1";
        guowai.action = @"wsjlList";
        guowai.service = @"DepartmentbService";
    [self.ViewController.navigationController pushViewController: guowai  animated:YES];
}
if ([_array[UIButton.tag] isEqualToString:@"国外活动"]) {
    guoneiwaiViewController *guowai = [[guoneiwaiViewController alloc]init];
        guowai.string = @"国外活动";
        guowai.type = @"2";
        guowai.action = @"wsjlList";
        guowai.service = @"DepartmentbService";
    [self.ViewController.navigationController pushViewController: guowai  animated:YES];
}
if ([_array[UIButton.tag] isEqualToString:@"国内接待"]) {
    guoneiwaiViewController *guowai = [[guoneiwaiViewController alloc]init];
        guowai.string = @"国内活动";
        guowai.type = @"1";
        guowai.action = @"wsjdList";
        guowai.service = @"DepartmentbService";
    [self.ViewController.navigationController pushViewController: guowai  animated:YES];
}
if ([_array[UIButton.tag] isEqualToString:@"国外接待"]) {
    guoneiwaiViewController *guowai = [[guoneiwaiViewController alloc]init];
        guowai.string = @"国外接待";
        guowai.type = @"2";
        guowai.action = @"wsjdList";
        guowai.service = @"DepartmentbService";
    [self.ViewController.navigationController pushViewController: guowai  animated:YES];
}

if ([_array[UIButton.tag] isEqualToString:@"培训"]) {
    huiyiguanliTableViewController *guowai = [[huiyiguanliTableViewController alloc]init];
        guowai.string = @"培训";
        guowai.type = @"1";
        guowai.action = @"xchdList";
        guowai.service = @"DepartmentbService";
    [self.ViewController.navigationController pushViewController: guowai  animated:YES];
}
if ([_array[UIButton.tag] isEqualToString:@"考查走访"]) {
    huiyiguanliTableViewController *guowai = [[huiyiguanliTableViewController alloc]init];
        guowai.string = @"考查走访";
        guowai.type = @"2";
        guowai.action = @"xchdList";
        guowai.service = @"DepartmentbService";
    [self.ViewController.navigationController pushViewController: guowai  animated:YES];
}
if ([_array[UIButton.tag] isEqualToString:@"联系机构"]) {
    huiyiguanliTableViewController *guowai = [[huiyiguanliTableViewController alloc]init];
        guowai.string = @"联系机构";
        guowai.type = @"3";
        guowai.action = @"xchdList";
        guowai.service = @"DepartmentbService";
    [self.ViewController.navigationController pushViewController: guowai  animated:YES];
}





}
- (void)layoutSubviews{
[super layoutSubviews];
view.frame =  CGRectMake(5, 5, KScreenWidth-10, self.contentView.height-10);
float itemWidth = (view.width-160) /4;
for (int j = 0;j<_array.count;j++)
         {
         _button = [UIButton buttonWithType:UIButtonTypeCustom];
       

                    _button.tag = j;
   
     [_button addTarget:self action:@selector(oneAction:) forControlEvents:UIControlEventTouchUpInside];
if (j>=4) {
    _button.frame  = CGRectMake(20+(itemWidth+40)*(j-4), 5+(itemWidth+20), itemWidth, itemWidth);

}
if (j<4){
_button.frame  = CGRectMake(20+(itemWidth+40)*j, 5, itemWidth, itemWidth);
}
 [_button setBackgroundImage:[UIImage imageNamed:_array[j]] forState:UIControlStateNormal];
  _label = [[UILabel alloc]init];

_label.frame = CGRectMake(_button.left-10, _button.bottom+5, _button.width+20, 10);
_label.font = [UIFont systemFontOfSize:10];//采用系统默认文字设置大小
_label.textAlignment = NSTextAlignmentCenter;
    _label.text = _array[j];
    [view addSubview:_label];
 [view addSubview:_button];
         
         
         
         }
         



}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
@end
